/**
 * Copyright 2025 Adobe. All rights reserved.
 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. You may obtain a copy
 * of the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
 * OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */

:host {
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    box-sizing: border-box;
    font-family: var(--mod-button-font-family, var(--mod-sans-font-family-stack, var(--spectrum-sans-font-family-stack)));
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: var(--mod-button-line-height, var(--mod-line-height-100, var(--spectrum-line-height-100)));
    text-transform: none;
    vertical-align: top;
    -webkit-appearance: button;
    transition:
        background var(--mod-button-animation-duration, var(--mod-animation-duration-100, var(--spectrum-animation-duration-100))) ease-out,
        border-color var(--mod-button-animation-duration, var(--mod-animation-duration-100, var(--spectrum-animation-duration-100))) ease-out,
        color var(--mod-button-animation-duration, var(--mod-animation-duration-100, var(--spectrum-animation-duration-100))) ease-out,
        box-shadow var(--mod-button-animation-duration, var(--mod-animation-duration-100, var(--spectrum-animation-duration-100))) ease-out;
    border-style: solid;
    justify-content: center;
    align-items: center;
    margin: 0;
    -webkit-text-decoration: none;
    text-decoration: none;
    display: inline-flex;
    overflow: visible;
}

:host(:focus) {
    outline: none;
}

:host([disabled]),
:host([disabled]) {
    cursor: default;
}

::slotted([slot="icon"]) {
    max-block-size: 100%;
    flex-shrink: 0;
}

#label {
    text-align: center;
    place-self: center;
}

#label:empty {
    display: none;
}

@media (forced-colors: active) {
    :host {
        --highcontrast-actionbutton-focus-indicator-color: ButtonText;
        --highcontrast-actionbutton-content-color: ButtonText;
    }

    :host:after {
        forced-color-adjust: none;
    }

    :host([selected]) {
        --highcontrast-actionbutton-background-color: Highlight;
        --highcontrast-actionbutton-border-color: HighlightText;
        --highcontrast-actionbutton-content-color: HighlightText;
    }

    :host([selected]) .hold-affordance,
    :host([selected]) ::slotted([slot="icon"]),
    :host([selected]) #label {
        forced-color-adjust: none;
    }

    :host([disabled]),
    :host([disabled]) {
        --highcontrast-actionbutton-content-color: GrayText;
        --highcontrast-actionbutton-border-color: GrayText;
        --highcontrast-actionbutton-background-color: ButtonFace;
    }
}

:host {
    --spectrum-actionbutton-background-color: var(--highcontrast-actionbutton-background-color, var(--mod-actionbutton-background-color-default, var(--spectrum-actionbutton-background-color-default)));
    --spectrum-actionbutton-border-color: var(--highcontrast-actionbutton-border-color, var(--mod-actionbutton-border-color-default, var(--spectrum-actionbutton-border-color-default)));
    --spectrum-actionbutton-content-color: var(--highcontrast-actionbutton-content-color, var(--mod-actionbutton-content-color-default, var(--spectrum-neutral-content-color-default)));
    --spectrum-actionbutton-border-radius: var(--mod-actionbutton-border-radius, var(--spectrum-actionbutton-border-radius-default));
    --spectrum-actionbutton-border-width: var(--mod-actionbutton-border-width, var(--spectrum-border-width-100));
    --spectrum-actionbutton-focus-indicator-gap: var(--mod-actionbutton-focus-indicator-gap, var(--spectrum-focus-indicator-gap));
    --spectrum-actionbutton-focus-indicator-thickness: var(--mod-actionbutton-focus-indicator-thickness, var(--spectrum-focus-indicator-thickness));
    --spectrum-actionbutton-focus-indicator-color: var(--highcontrast-actionbutton-focus-indicator-color, var(--mod-actionbutton-focus-indicator-color, var(--spectrum-focus-indicator-color)));
}

:host:dir(rtl),
:host([dir="rtl"]) {
    --spectrum-logical-rotation: matrix(-1, 0, 0, 1, 0, 0);
}

:host([quiet]) {
    --spectrum-actionbutton-border-color: transparent;
}

:host([emphasized]:not([static-color="black"], [static-color="white"])) {
    --mod-actionbutton-background-color-default-selected: var(--mod-actionbutton-background-color-default-selected-emphasized, var(--spectrum-accent-background-color-default));
    --mod-actionbutton-background-color-hover-selected: var(--mod-actionbutton-background-color-hover-selected-emphasized, var(--spectrum-accent-background-color-hover));
    --mod-actionbutton-background-color-down-selected: var(--mod-actionbutton-background-color-down-selected-emphasized, var(--spectrum-accent-background-color-down));
    --mod-actionbutton-background-color-focus-selected: var(--mod-actionbutton-background-color-focus-selected-emphasized, var(--spectrum-accent-background-color-key-focus));
    --mod-actionbutton-content-color-default-selected: var(--mod-actionbutton-content-color-default-selected-emphasized, var(--spectrum-white));
    --mod-actionbutton-content-color-hover-selected: var(--mod-actionbutton-content-color-hover-selected-emphasized, var(--spectrum-white));
    --mod-actionbutton-content-color-down-selected: var(--mod-actionbutton-content-color-down-selected-emphasized, var(--spectrum-white));
    --mod-actionbutton-content-color-focus-selected: var(--mod-actionbutton-content-color-focus-selected-emphasized, var(--spectrum-white));
}

:host([static-color="black"]) {
    --mod-actionbutton-background-color-default-selected: var(--spectrum-transparent-black-800);
    --mod-actionbutton-background-color-hover-selected: var(--spectrum-transparent-black-900);
    --mod-actionbutton-background-color-down-selected: var(--spectrum-transparent-black-900);
    --mod-actionbutton-background-color-focus-selected: var(--spectrum-transparent-black-900);
    --mod-actionbutton-content-color-default: var(--spectrum-black);
    --mod-actionbutton-content-color-hover: var(--spectrum-black);
    --mod-actionbutton-content-color-down: var(--spectrum-black);
    --mod-actionbutton-content-color-focus: var(--spectrum-black);
    --mod-actionbutton-content-color-disabled: var(--spectrum-disabled-static-black-content-color);
    --mod-actionbutton-content-color-default-selected: var(--mod-actionbutton-static-content-color, var(--spectrum-white));
    --mod-actionbutton-content-color-hover-selected: var(--mod-actionbutton-static-content-color, var(--spectrum-white));
    --mod-actionbutton-content-color-down-selected: var(--mod-actionbutton-static-content-color, var(--spectrum-white));
    --mod-actionbutton-content-color-focus-selected: var(--mod-actionbutton-static-content-color, var(--spectrum-white));
    --mod-actionbutton-focus-indicator-color: var(--spectrum-static-black-focus-indicator-color);
}

:host([static-color="white"]) {
    --mod-actionbutton-background-color-default-selected: var(--spectrum-transparent-white-800);
    --mod-actionbutton-background-color-hover-selected: var(--spectrum-transparent-white-900);
    --mod-actionbutton-background-color-down-selected: var(--spectrum-transparent-white-900);
    --mod-actionbutton-background-color-focus-selected: var(--spectrum-transparent-white-900);
    --mod-actionbutton-content-color-default: var(--spectrum-white);
    --mod-actionbutton-content-color-hover: var(--spectrum-white);
    --mod-actionbutton-content-color-down: var(--spectrum-white);
    --mod-actionbutton-content-color-focus: var(--spectrum-white);
    --mod-actionbutton-content-color-disabled: var(--spectrum-disabled-static-white-content-color);
    --mod-actionbutton-content-color-default-selected: var(--mod-actionbutton-static-content-color, var(--spectrum-black));
    --mod-actionbutton-content-color-hover-selected: var(--mod-actionbutton-static-content-color, var(--spectrum-black));
    --mod-actionbutton-content-color-down-selected: var(--mod-actionbutton-static-content-color, var(--spectrum-black));
    --mod-actionbutton-content-color-focus-selected: var(--mod-actionbutton-static-content-color, var(--spectrum-black));
    --mod-actionbutton-focus-indicator-color: var(--spectrum-static-white-focus-indicator-color);
}

:host([selected]) {
    --mod-actionbutton-background-color-default: var(--mod-actionbutton-background-color-default-selected, var(--spectrum-actionbutton-background-color-selected));
    --mod-actionbutton-background-color-hover: var(--mod-actionbutton-background-color-hover-selected, var(--spectrum-actionbutton-background-color-selected-hover));
    --mod-actionbutton-background-color-down: var(--mod-actionbutton-background-color-down-selected, var(--spectrum-actionbutton-background-color-selected-down));
    --mod-actionbutton-background-color-focus: var(--mod-actionbutton-background-color-focus-selected, var(--spectrum-actionbutton-background-color-selected-focus));
    --mod-actionbutton-background-color-disabled: var(--spectrum-actionbutton-background-color-selected-disabled);
    --mod-actionbutton-border-color-default: transparent;
    --mod-actionbutton-border-color-hover: transparent;
    --mod-actionbutton-border-color-down: transparent;
    --mod-actionbutton-border-color-focus: transparent;
    --mod-actionbutton-border-color-disabled: transparent;
    --mod-actionbutton-content-color-default: var(--mod-actionbutton-content-color-default-selected, var(--spectrum-actionbutton-content-color-selected));
    --mod-actionbutton-content-color-hover: var(--mod-actionbutton-content-color-hover-selected, var(--spectrum-actionbutton-content-color-selected));
    --mod-actionbutton-content-color-down: var(--mod-actionbutton-content-color-down-selected, var(--spectrum-actionbutton-content-color-selected));
    --mod-actionbutton-content-color-focus: var(--mod-actionbutton-content-color-focus-selected, var(--spectrum-actionbutton-content-color-selected));
}

@media (hover: hover) {
    :host(:hover) {
        --mod-actionbutton-background-color-default: var(--mod-actionbutton-background-color-hover, var(--spectrum-actionbutton-background-color-hover));
        --mod-actionbutton-border-color-default: var(--mod-actionbutton-border-color-hover, var(--spectrum-actionbutton-border-color-hover));
        --mod-actionbutton-content-color-default: var(--mod-actionbutton-content-color-hover, var(--spectrum-neutral-content-color-hover));
    }
}

:host(:focus-visible) {
    --mod-actionbutton-background-color-default: var(--mod-actionbutton-background-color-focus, var(--spectrum-actionbutton-background-color-focus));
    --mod-actionbutton-border-color-default: var(--mod-actionbutton-border-color-focus, var(--spectrum-actionbutton-border-color-focus));
    --mod-actionbutton-content-color-default: var(--mod-actionbutton-content-color-focus, var(--spectrum-neutral-content-color-key-focus));
}

:host(:is(:active, [active])) {
    --mod-actionbutton-background-color-default: var(--mod-actionbutton-background-color-down, var(--spectrum-actionbutton-background-color-down));
    --mod-actionbutton-border-color-default: var(--mod-actionbutton-border-color-down, var(--spectrum-actionbutton-border-color-down));
    --mod-actionbutton-content-color-default: var(--mod-actionbutton-content-color-down, var(--spectrum-neutral-content-color-down));
}

:host([disabled]),
:host([disabled]) {
    --mod-actionbutton-background-color-default: var(--mod-actionbutton-background-color-disabled, var(--spectrum-actionbutton-background-color-disabled));
    --mod-actionbutton-border-color-default: var(--mod-actionbutton-border-color-disabled, var(--spectrum-actionbutton-border-color-disabled));
    --mod-actionbutton-content-color-default: var(--mod-actionbutton-content-color-disabled, var(--spectrum-disabled-content-color));
}

:host,
:host {
    --spectrum-actionbutton-sized-height: var(--spectrum-component-height-100);
    --spectrum-actionbutton-sized-icon-size: var(--spectrum-workflow-icon-size-100);
    --spectrum-actionbutton-sized-font-size: var(--spectrum-font-size-100);
    --spectrum-actionbutton-sized-text-to-visual: var(--spectrum-text-to-visual-100);
    --spectrum-actionbutton-sized-edge-to-hold-icon: var(--spectrum-action-button-edge-to-hold-icon-medium);
    --spectrum-actionbutton-sized-edge-to-visual: var(--spectrum-component-edge-to-visual-100);
    --spectrum-actionbutton-sized-edge-to-text: var(--spectrum-component-edge-to-text-100);
    --spectrum-actionbutton-sized-edge-to-visual-only: var(--spectrum-component-edge-to-visual-only-100);
}

:host([size="xs"]) {
    --spectrum-actionbutton-sized-height: var(--spectrum-component-height-50);
    --spectrum-actionbutton-sized-icon-size: var(--spectrum-workflow-icon-size-50);
    --spectrum-actionbutton-sized-font-size: var(--spectrum-font-size-50);
    --spectrum-actionbutton-sized-text-to-visual: var(--spectrum-text-to-visual-50);
    --spectrum-actionbutton-sized-edge-to-hold-icon: var(--spectrum-action-button-edge-to-hold-icon-extra-small);
    --spectrum-actionbutton-sized-edge-to-visual: var(--spectrum-component-edge-to-visual-50);
    --spectrum-actionbutton-sized-edge-to-text: var(--spectrum-component-edge-to-text-50);
    --spectrum-actionbutton-sized-edge-to-visual-only: var(--spectrum-component-edge-to-visual-only-50);
}

:host([size="s"]) {
    --spectrum-actionbutton-sized-height: var(--spectrum-component-height-75);
    --spectrum-actionbutton-sized-icon-size: var(--spectrum-workflow-icon-size-75);
    --spectrum-actionbutton-sized-font-size: var(--spectrum-font-size-75);
    --spectrum-actionbutton-sized-text-to-visual: var(--spectrum-text-to-visual-75);
    --spectrum-actionbutton-sized-edge-to-hold-icon: var(--spectrum-action-button-edge-to-hold-icon-small);
    --spectrum-actionbutton-sized-edge-to-visual: var(--spectrum-component-edge-to-visual-75);
    --spectrum-actionbutton-sized-edge-to-text: var(--spectrum-component-edge-to-text-75);
    --spectrum-actionbutton-sized-edge-to-visual-only: var(--spectrum-component-edge-to-visual-only-75);
}

:host([size="l"]) {
    --spectrum-actionbutton-sized-height: var(--spectrum-component-height-200);
    --spectrum-actionbutton-sized-icon-size: var(--spectrum-workflow-icon-size-200);
    --spectrum-actionbutton-sized-font-size: var(--spectrum-font-size-200);
    --spectrum-actionbutton-sized-text-to-visual: var(--spectrum-text-to-visual-200);
    --spectrum-actionbutton-sized-edge-to-hold-icon: var(--spectrum-action-button-edge-to-hold-icon-large);
    --spectrum-actionbutton-sized-edge-to-visual: var(--spectrum-component-edge-to-visual-200);
    --spectrum-actionbutton-sized-edge-to-text: var(--spectrum-component-edge-to-text-200);
    --spectrum-actionbutton-sized-edge-to-visual-only: var(--spectrum-component-edge-to-visual-only-200);
}

:host([size="xl"]) {
    --spectrum-actionbutton-sized-height: var(--spectrum-component-height-300);
    --spectrum-actionbutton-sized-icon-size: var(--spectrum-workflow-icon-size-300);
    --spectrum-actionbutton-sized-font-size: var(--spectrum-font-size-300);
    --spectrum-actionbutton-sized-text-to-visual: var(--spectrum-text-to-visual-300);
    --spectrum-actionbutton-sized-edge-to-hold-icon: var(--spectrum-action-button-edge-to-hold-icon-extra-large);
    --spectrum-actionbutton-sized-edge-to-visual: var(--spectrum-component-edge-to-visual-300);
    --spectrum-actionbutton-sized-edge-to-text: var(--spectrum-component-edge-to-text-300);
    --spectrum-actionbutton-sized-edge-to-visual-only: var(--spectrum-component-edge-to-visual-only-300);
}

:host {
    --spectrum-actionbutton-height: var(--mod-actionbutton-height, var(--spectrum-actionbutton-sized-height));
    --spectrum-actionbutton-icon-size: var(--mod-actionbutton-icon-size, var(--spectrum-actionbutton-sized-icon-size));
    --spectrum-actionbutton-font-size: var(--mod-actionbutton-font-size, var(--spectrum-actionbutton-sized-font-size));
    --spectrum-actionbutton-text-to-visual: var(--mod-actionbutton-text-to-visual, var(--spectrum-actionbutton-sized-text-to-visual));
    --spectrum-actionbutton-edge-to-hold-icon: var(--mod-actionbutton-edge-to-hold-icon, var(--spectrum-actionbutton-sized-edge-to-hold-icon));
    --spectrum-actionbutton-edge-to-visual: var(--mod-actionbutton-edge-to-visual, calc(var(--spectrum-actionbutton-sized-edge-to-visual) - var(--spectrum-actionbutton-border-width)));
    --spectrum-actionbutton-edge-to-text: var(--mod-actionbutton-edge-to-text, calc(var(--spectrum-actionbutton-sized-edge-to-text) - var(--spectrum-actionbutton-border-width)));
    --spectrum-actionbutton-edge-to-visual-only: var(--mod-actionbutton-edge-to-visual-only, calc(var(--spectrum-actionbutton-sized-edge-to-visual-only) - var(--spectrum-actionbutton-border-width)));
    min-inline-size: var(--mod-actionbutton-min-width, calc(var(--mod-actionbutton-edge-to-visual-only, var(--spectrum-actionbutton-sized-edge-to-visual-only)) * 2 + var(--spectrum-actionbutton-icon-size)));
    block-size: var(--spectrum-actionbutton-height);
    border-radius: var(--spectrum-actionbutton-border-radius);
    border-width: var(--spectrum-actionbutton-border-width);
    gap: calc(var(--spectrum-actionbutton-text-to-visual) + var(--spectrum-actionbutton-edge-to-text) - var(--spectrum-actionbutton-edge-to-visual-only));
    padding-inline: var(--spectrum-actionbutton-edge-to-text);
    background-color: var(--spectrum-actionbutton-background-color);
    border-color: var(--spectrum-actionbutton-border-color);
    color: var(--spectrum-actionbutton-content-color);
    transition: border-color var(--mod-actionbutton-animation-duration, var(--spectrum-animation-duration-100)) ease-in-out;
    position: relative;
}

:host:after {
    margin: calc((var(--spectrum-actionbutton-focus-indicator-gap) + var(--spectrum-actionbutton-border-width)) * -1);
    border-radius: var(--mod-actionbutton-focus-indicator-border-radius, calc(var(--spectrum-actionbutton-border-radius) + var(--spectrum-actionbutton-focus-indicator-gap)));
    transition: box-shadow var(--mod-actionbutton-animation-duration, var(--spectrum-animation-duration-100)) ease-in-out;
    pointer-events: none;
    content: "";
    position: absolute;
    inset: 0;
}

:host(:focus-visible) {
    box-shadow: none;
    outline: none;
}

:host(:focus-visible):after {
    box-shadow: 0 0 0 var(--spectrum-actionbutton-focus-indicator-thickness) var(--spectrum-actionbutton-focus-indicator-color);
}

::slotted([slot="icon"]) {
    inline-size: var(--spectrum-actionbutton-icon-size);
    block-size: var(--spectrum-actionbutton-icon-size);
    color: inherit;
    margin-inline-start: calc(var(--spectrum-actionbutton-edge-to-visual) - var(--spectrum-actionbutton-edge-to-text));
    margin-inline-end: calc(var(--spectrum-actionbutton-edge-to-visual-only) - var(--spectrum-actionbutton-edge-to-text));
}

.hold-affordance + ::slotted([slot="icon"]),
[icon-only]::slotted([slot="icon"]) {
    margin-inline-start: calc(var(--spectrum-actionbutton-edge-to-visual-only) - var(--spectrum-actionbutton-edge-to-text));
}

#label {
    pointer-events: none;
    line-height: var(--spectrum-actionbutton-height);
    font-size: var(--spectrum-actionbutton-font-size);
    white-space: nowrap;
    color: var(--mod-actionbutton-label-color, inherit);
    text-overflow: ellipsis;
    overflow: hidden;
}

.hold-affordance {
    color: inherit;
    transform: var(--spectrum-logical-rotation,);
    position: absolute;
    inset-block-end: calc(var(--spectrum-actionbutton-edge-to-hold-icon) - var(--spectrum-actionbutton-border-width));
    inset-inline-end: calc(var(--spectrum-actionbutton-edge-to-hold-icon) - var(--spectrum-actionbutton-border-width));
}
